<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        
        const p = new Promise((resolve , reject) => {
            setTimeout(() => {
                let n = parseInt(Math.random() * 100) ;
                if(n % 2) {
                    resolve(n) ;
                } else {
                    reject(n) ;
                }
            })
        })


        // p.then()
        // p.catch()
        // p.finally()


        p 
            .then(data => {
                console.log(data);
            })
            .catch(data => {
                console.log(data);
            }) 
            .finally(() => {
                console.log('反正都会执行');
            })


        // 链式操作  说明   then和catch方法实际上也返回了一个p

    </script>
    
</body>
</html>